import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Profile from '../views/Profile.vue'
import Explore from '../views/Explore.vue'
import Notifications from '../views/Notifications.vue'
import Messages from '../views/Messages.vue'
import UserList from '../views/UserList.vue'
import Login from '../components/auth/Login.vue'
import Register from '../components/auth/Register.vue'
import authGuard from './guards/authGuard'
import PostDetails from '@/components/posts/PostDetails.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    beforeEnter: authGuard
  },
  {
    path: '/profile/:id?',
    name: 'Profile',
    component: Profile,
    beforeEnter: authGuard
  },
  {
    path: '/explore',
    name: 'Explore',
    component: Explore,
    beforeEnter: authGuard
  },
  {
    path: '/notifications',
    name: 'Notifications',
    component: Notifications,
    beforeEnter: authGuard
  },
  {
    path: '/messages',
    name: 'Messages',
    component: Messages,
    beforeEnter: authGuard
  },
  {
    path: '/users',
    name: 'UserList',
    component: UserList,
    beforeEnter: authGuard
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/posts/:id',
    name: 'PostDetails',
    component: PostDetails,
    beforeEnter: authGuard
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior() {
    return { top: 0 }
  }
})

export default router